<template>
  <el-tag v-if="statusDict" :type="statusDict.listClass ? statusDict.listClass : ''">{{ statusDict.dictLabel }}</el-tag>
</template>

<script>
export default {
  name: "StatusTag",
  props: {
    statusOptions: {
      type: Array,
      default: []
    },
    status: {
      type: String
    }
  },
  data() {
    return {
      statusDict: null
    }
  },
  created() {
    this.statusFormat();
  },
  methods: {
    // 任务组名字典翻译
    statusFormat() {
      this.$lodash.each(this.statusOptions, item => {
        if (item.dictValue === this.status) {
          this.statusDict = item;
          return false;
        }
      });
    }
  },
  watch: {
    status(val) {
      this.statusDict = null;
      this.statusFormat();
    },
    statusOptions(val) {
      this.statusDict = null;
      this.statusFormat();
    }
  }
}
</script>

<style scoped>

</style>
